#ifndef SPARSE_H
#define SPARSE_H
#include "array.h"

typedef float real;

/* A class representing a sparse vector */
class svector {
    struct entry {
        int ind;
        real val;
    };
    entry *buf;
    int len;
    int label;
    float norm;
public:
    svector(int l, const Array<int>& ai, const Array<real>& av);
    svector();
    svector(const svector& v);
    svector& operator=(const svector& v);
    ~svector();
    void at(int i, int& ind, real& val) const;
    real dot(const svector& v) const;
    real dot(const Array<real>& v) const;
    void update(Array<real>& v) const;
    const int getClass() const;
    const int size() const;
    const float getNorm();
};
#endif
